#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :weather_spider.py
# @Time      :2021/6/27 0:38
# @Author    : 刘广鸿
import requests
from lxml import etree
from config.config import shzx_app
from url.urls import URLS


@shzx_app.get(URLS[10])
def get24Temp():
    html = etree.HTML(requests.get("http://tianqi.sogou.com/pc/weather").text)
    weather = []
    temps = html.xpath("//li[@class='list-item']/p[@class='temp']/text()")
    times = html.xpath("//li[@class='list-item']/p[@class='time']/text()")
    for time, temp in zip(times, temps):
        if time == "明天":
            continue
        dictT = {"time": time[:2], "temp": temp}
        weather.append(dictT)
    return weather
